package com.neuedu.web.controller.system;

import java.util.List;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.common.annotation.Log;
import com.neuedu.common.core.controller.BaseController;
import com.neuedu.common.core.domain.AjaxResult;
import com.neuedu.common.enums.BusinessType;
import com.neuedu.system.domain.AgriculturalReports;
import com.neuedu.system.service.IAgriculturalReportsService;
import com.neuedu.common.utils.poi.ExcelUtil;
import com.neuedu.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 农业报告基本信息Controller
 *
 * @author ruoyi
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/system/reports")
@Tag(name = "【农业报告基本信息】管理")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AgriculturalReportsController extends BaseController
{
    private final IAgriculturalReportsService agriculturalReportsService;

    /**
     * 查询农业报告基本信息列表
     */
    @Operation(summary = "查询农业报告基本信息列表")
    @PreAuthorize("@ss.hasPermi('system:reports:list')")
    @GetMapping("/list")
    public TableDataInfo list(AgriculturalReports agriculturalReports)
    {
        startPage();
        List<AgriculturalReports> list = agriculturalReportsService.selectAgriculturalReportsList(agriculturalReports);
        return getDataTable(list);
    }

    /**
     * 导出农业报告基本信息列表
     */
    @Operation(summary = "导出农业报告基本信息列表")
    @PreAuthorize("@ss.hasPermi('system:reports:export')")
    @Log(title = "农业报告基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AgriculturalReports agriculturalReports)
    {
        List<AgriculturalReports> list = agriculturalReportsService.selectAgriculturalReportsList(agriculturalReports);
        ExcelUtil<AgriculturalReports> util = new ExcelUtil<AgriculturalReports>(AgriculturalReports.class);
        util.exportExcel(response, list, "农业报告基本信息数据");
    }

    /**
     * 获取农业报告基本信息详细信息
     */
    @Operation(summary = "获取农业报告基本信息详细信息")
    @PreAuthorize("@ss.hasPermi('system:reports:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(agriculturalReportsService.selectAgriculturalReportsById(id));
    }

    /**
     * 新增农业报告基本信息
     */
    @Operation(summary = "新增农业报告基本信息")
    @PreAuthorize("@ss.hasPermi('system:reports:add')")
    @Log(title = "农业报告基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AgriculturalReports agriculturalReports)
    {
        return toAjax(agriculturalReportsService.insertAgriculturalReports(agriculturalReports));
    }

    /**
     * 修改农业报告基本信息
     */
    @Operation(summary = "修改农业报告基本信息")
    @PreAuthorize("@ss.hasPermi('system:reports:edit')")
    @Log(title = "农业报告基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AgriculturalReports agriculturalReports)
    {
        return toAjax(agriculturalReportsService.updateAgriculturalReports(agriculturalReports));
    }

    /**
     * 删除农业报告基本信息
     */
    @Operation(summary = "删除农业报告基本信息")
    @PreAuthorize("@ss.hasPermi('system:reports:remove')")
    @Log(title = "农业报告基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable( name = "ids" ) Long[] ids)
    {
        return toAjax(agriculturalReportsService.deleteAgriculturalReportsByIds(ids));
    }
}
